package com.mk.admin.controller;

import com.mk.admin.model.ResultDto;
import com.mk.admin.model.query.*;
import com.mk.admin.model.vo.*;
import com.mk.admin.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/task")
@Api(tags = "定时任务手动刷新接口")
public class TaskController {
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private MedicalTechnologyProjectService medicalTechnologyProjectService;
    @Autowired
    private PatientMedicalRecordService patientMedicalRecordService;
    @Autowired
    private MedicalTechnologyReportService medicalTechnologyReportService;
    @Autowired
    private CampusService campusService;
    @Autowired
    private PhysicalService physicalService;
    @Autowired
    private SelfBillingProjectService selfBillingProjectService;
    @Autowired
    private AdminService adminService;

    @PostMapping("/department")
    @ApiOperation(value = "opt_0002科室同步刷新", notes = "刷新科室可更新院区和科室")
    public ResultDto department() {
        return departmentService.fresh();
    }

    @PostMapping("/campus")
    @ApiOperation(value = "查询多少个院区", notes = "查询所有院区")
    public ResultDto campus(@RequestBody CampusRemoteQuery query) {
        return campusService.fresh(query);
    }

    @PostMapping("/campusCode")
    @ApiOperation(value = "根据院区编码查询院区详细信息", notes = "根据院区编码查询院区详细信息")
    public ResultDto campusCode(@RequestBody CampusCodeQuery query) {
        return campusService.campusCode(query);
    }

    @PostMapping("/campusUser")
    @ApiOperation(value = "查询医院员工信息", notes = "查询医院员工信息")
    public ResultDto campusUser(@RequestBody CampusUserQuery query) {
        return campusService.campusUser(query);
    }

    @PostMapping("/clear")
    @ApiOperation(value = "清空常规表数据(慎重)", notes = "换院区时或新项目时,保留配置表数据,tables: []为空默认删除某些表，指定删除某些表直接封装到数组即可")
    public ResultDto clear(@RequestBody ClearVo vo) {
        return departmentService.clear(vo);
    }


    @PostMapping("/medicalTechnologyProject")
    @ApiOperation(value = "医技具体项目刷新", notes = "如果不传，则更新检验检查项目")
    public ResultDto medicalTechnologyProject(@RequestBody MedicalTechnologyProjectRemoteVo vo) {
        return medicalTechnologyProjectService.fresh(vo);
    }

    @PostMapping("/selfBillingProject")
    @ApiOperation(value = "自助开单项目刷新", notes = "如果不传，则更新检验检查项目")
    public ResultDto selfBillingProject(@RequestBody SelfBillingProjectRemoteQuery query) {
        return selfBillingProjectService.fresh(query);
    }

    @PostMapping("/patientMedicalRecord")
    @ApiOperation(value = "查询患者病历详情（日期降序排序），如不传卡号信息则日期必传，查询所有患者的病历", notes = "卡类型 1 就诊卡2 社保卡3 健康卡\n" +
            "4 身份证号5 病历号\n" +
            "6 姓名7 手机号\n" +
            "8 patId 9 发票号（需要his）\n" +
            "结束日期 格式yyyy-MM-dd，如果开始日期和结束日期不填写，查询最近一次\n" +
            "查询具体患者可直接传递patId给cardNo即可")
    public ResultDto patientMedicalRecord(@RequestBody PatientMedicalRecordRemoteVo patientMedicalRecordRemoteVo) {
        return patientMedicalRecordService.report(patientMedicalRecordRemoteVo);
    }

    @PostMapping("/medicalTechnologyReport")
    @ApiOperation(value = "检查报告查询", notes = "queryType 1 就诊卡2 社保卡\n" +
            "3 健康卡号4 身份证号\n" +
            "5 门诊病历号6 姓名\n" +
            "7 手机号8 门诊patId\n" +
            "9 发票号（需要his）\n" +
            "10港澳证件号\n" +
            "11台湾证件号\n" +
            "12护照号码\n" +
            "13住院门诊号\n" +
            "14门诊就诊号\n" +
            "15住院病历号\n" +
            "16住院patId，17挂号ID\n" +
            "queryValue beginTime endTime yyyy-MM-dd HH:mm:ss")
    public ResultDto medicalTechnologyReport(@RequestBody MedicalTechnologyReportRemoteVo vo) {
        return medicalTechnologyReportService.check(vo);
    }

    @PostMapping("/physicalFresh")
    @ApiOperation("体检套餐刷新")
    public ResultDto physicalFresh(@RequestBody PhysicalVo vo) {
        return physicalService.fresh(vo);
    }

    @PostMapping("/allTable")
    @ApiOperation("查询所有表及注释")
    public ResultDto allTable(@RequestBody TableQuery query) {
        return adminService.allTable(query);
    }

}
